#include "sortAlgorithm.h"

void fastsort(std::vector<int>& nums,int left,int right){
    if(left>right)
        return;
    int l=left,r=right;
    int privot = nums[l];
    while (l!=r){
        while (nums[r]>=privot&&l<r)
            r--;
        while (nums[l]<=privot&&l<r)
            l++;
        if(l<r)
            std::swap(nums[l],nums[r]);
    }
    nums[left]=nums[l];
    nums[l]=privot;
    fastsort(nums,left,l-1);
    fastsort(nums,l+1,right);
}

void fastsort1(std::vector<int>& nums,int left,int right){
    if(left>right)
        return;
    int l=left,r=right;
    int privot = nums[l];
    while (l!=r){
        while (nums[r]>=privot&&l<r)
            r--;
        while (nums[l]<=privot&&l<r)
            l++;
        if(l<r)
            std::swap(nums[l],nums[r]);
    }
    nums[left]=nums[l];
    nums[l]=privot;
    fastsort1(nums,left,l-1);
    fastsort1(nums,l+1,right);

}
